package xyz.xuminghai.javafx_learn.scene.control;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;

import java.io.FileNotFoundException;
import java.net.URL;

/**
 * 2023/5/20 1:56 星期六<br/>
 * 滚动窗口
 *
 * @author xuMingHai
 */
public class ScrollPaneApp extends Application {

    private final ScrollPane scrollPane = new ScrollPane();

    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void init() throws Exception {
        String fileName = "scroll-pane-app.png";
        URL url = getClass().getResource(fileName);
        if (url == null) {
            throw new FileNotFoundException(fileName);
        }

        scrollPane.setContent(new ImageView(url.toExternalForm()));
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle(getClass().getSimpleName());
        Scene scene = new Scene(scrollPane, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
